package com.letoken.platform.app.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.app.service.AppArticleService;
import com.letoken.platform.pub.constant.AdminArticleConstant;
import com.letoken.platform.pub.constant.RedisKeyConstant;
import com.letoken.platform.repo.admin.dao.ArticleMapper;
import com.letoken.platform.repo.admin.po.Article;
import com.letoken.platform.repo.app.redis.AppJsonStringRedis;
import com.letoken.platform.repo.app.res.assets.QueryAnnDetailRes;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author wyl
 * @date 2022/12/28 19:11
 * @Version 1.0
 */
@Service
@Log4j2
public class AppArticleServiceImpl implements AppArticleService {
    @Autowired
    private ArticleMapper articleMapper;

    @Cacheable(cacheNames = RedisKeyConstant.AGREEMENT, key = "'agreement'", sync = true)
    @Override
    public String queryUserAgreementList() {
        LambdaQueryWrapper<Article> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(Article::getName, AdminArticleConstant.USER_AGREEMENT);
        Article article = articleMapper.selectOne(wrapper);
        return article.getContent();
    }

    @Cacheable(cacheNames = RedisKeyConstant.ABOUT_US, key = "'aboutUs'", sync = true)
    @Override
    public String queryAboutUsList() {

        LambdaQueryWrapper<Article> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(Article::getName, AdminArticleConstant.ABOUT_US);
        Article article = articleMapper.selectOne(wrapper);
        return article.getContent();
    }
}
